package com.xiaoma.lock.syn;

import com.google.common.base.Objects;
import org.springframework.util.StringUtils;

public class Person {

    private String name;
    private String age;

    public Person(String name, String age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
  /*      if(obj instanceof Person){
            Person other = (Person) obj;
            //需要比较的字段相等，则这两个对象相等
            if(equalsStr(this.name, other.name)
                    && equalsStr(this.age, other.age)){
                return true;
            }
        }*/

        return true;
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(name, age);
    }

    private boolean equalsStr(String str1, String str2){
        if(StringUtils.isEmpty(str1) && StringUtils.isEmpty(str2)){
            return true;
        }
        if(!StringUtils.isEmpty(str1) && str1.equals(str2)){
            return true;
        }
        return false;
    }
}
